package org.jeecg.modules.nurse_nurses.service.impl;

import org.jeecg.modules.nurse_nurses.entity.NurseNurses;
import org.jeecg.modules.nurse_nurses.entity.NurseNursesCertificate;
import org.jeecg.modules.nurse_nurses.entity.NurseNursesComment;
import org.jeecg.modules.nurse_nurses.mapper.NurseNursesCertificateMapper;
import org.jeecg.modules.nurse_nurses.mapper.NurseNursesCommentMapper;
import org.jeecg.modules.nurse_nurses.mapper.NurseNursesMapper;
import org.jeecg.modules.nurse_nurses.service.INurseNursesService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 护工管理
 * @Author: jeecg-boot
 * @Date: 2024-06-04
 * @Version: V1.0
 */
@Service
public class NurseNursesServiceImpl extends ServiceImpl<NurseNursesMapper, NurseNurses> implements INurseNursesService {

    @Autowired
    private NurseNursesMapper nurseNursesMapper;
    @Autowired
    private NurseNursesCertificateMapper nurseNursesCertificateMapper;
    @Autowired
    private NurseNursesCommentMapper nurseNursesCommentMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        nurseNursesCertificateMapper.deleteByMainId(id);
        nurseNursesCommentMapper.deleteByMainId(id);
        nurseNursesMapper.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for (Serializable id : idList) {
            nurseNursesCertificateMapper.deleteByMainId(id.toString());
            nurseNursesCommentMapper.deleteByMainId(id.toString());
            nurseNursesMapper.deleteById(id);
        }
    }

    @Override
    public List<NurseNurses> listByWeChat(String hospital) {
        return nurseNursesMapper.listByWeChat(hospital);
    }

}
